{% extends 'base.html' %}
{% block before_head %}
    <script src="/static/js/md5.js"></script>
    <script src="/static/js/sticky.min.js"></script>

<script>


$(function() {
    var vm = new Vue({
        el: '#form_sign_in',
        data: {
            email: '',
            password: '',
            remember: false
        },
        methods: {
            submit: function (event) {
                event.preventDefault();
                var email = this.email.trim().toLowerCase();
                showError();
                startLoading();
                postApi('/api/sign_in', {
                    email: email,
                    password: CryptoJS.MD5(this.password).toString(),
                    remember: this.remember
                }, function (err, result) {
                    if (err) {
                        showError(err);
                    }
                    else {
                        return location.assign('{{redirect}}');
                    }
                    stopLoading();
                });
            }
        }
    });
})
    </script>
{% endblock %}

{% block title %}登录{% endblock %}
{% block content %}
    <div class="uk-vertical-align uk-text-center uk-height-1-1">
        <div class="uk-vertical-align-middle" style="width: 320px">

            <form id="form_sign_in" v-on="submit: submit" class="uk-panel uk-panel-box uk-form">
                <div class="uk-form-row">
                    <div class="uk-form-icon uk-width-1-1">
                        <i class="uk-icon-envelope-o"></i>
                        <input v-model="email" name="email" type="text" placeholder="邮箱" maxlength="50" class="uk-width-1-1 uk-form-large">
                    </div>
                </div>
                <div class="uk-form-row">
                    <div class="uk-form-icon uk-width-1-1">
                        <i class="uk-icon-lock"></i>
                        <input v-model="password" name="password" type="password" placeholder="密码" maxlength="50" class="uk-width-1-1 uk-form-large">
                    </div>
                </div>
                <div class="uk-form-row">
                    <button type="submit" class="uk-width-1-1 uk-button uk-button-primary uk-button-large"><i class="uk-icon-sign-in"></i> 登录</button>
                </div>
                <div class="uk-form-row uk-text-small">
                    <label class="uk-float-left"><input v-model="remember" type="checkbox"> 记住我</label>
                </div>
                <div class="uk-alert uk-alert-danger uk-hidden"></div>
            </form>
        </div>
    </div>
{% endblock %}
